﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="多国语言.aspx.cs" Inherits="Study.多国语言" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            var cookie = getCookie("USER_COOKIE");
            if (cookie != null) {
                var lang = cookie.split('=')[1];
                $("#lang").val(lang);
            }

            $("#lang").change(function () {
                var lang = $("#lang").val();
                $.ajax({
                    type: "post",
                    url: "Ajax/lang.ashx",
                    data: { lang: lang },
                    dataType: "json",
                    success: function (data) {
                        self.location.reload();
                    },
                    error: function (err) {
                        alert("错误:" + err);
                    }
                });
            });
        });

        function getCookie(name) {
            var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <select id="lang">
        <option value="zh-CN">简体中文</option>
        <option value="zh-HK">繁體中文(香港)</option>
        <option value="en-US">English</option>
    </select>
        <br />
        <br />
         <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:GlobalResource,name%>" />
    </div>
    </form>
</body>
</html>
